package com.cxx.home.controller;

import com.cxx.common.WriteView;
import com.cxx.home.dto.bill.BillCategoryDto;
import com.cxx.home.dto.bill.BillItemDto;
import com.cxx.home.service.BillManageService;
import com.fasterxml.jackson.annotation.JsonView;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/bill-manage")
@Tag(name = "账单管理")
public class BillManageController {
    @Resource
    private BillManageService billManageService;

    @Operation(summary = "新增支付账户")
    @PostMapping("/pay")
    public Boolean addBillPay(@JsonView(WriteView.class) @RequestBody BillItemDto billItemDto) {
        return billManageService.addBillPay(billItemDto);
    }

    @Operation(summary = "更新支付账户")
    @PutMapping("/pay/{id}")
    public Boolean updateBillPay(@PathVariable("id") Long id,
                                 @JsonView(WriteView.class) @RequestBody BillItemDto billItemDto) {
        return billManageService.updateBillPay(id, billItemDto);
    }

    @Operation(summary = "新增账本类型")
    @PostMapping("/book")
    public Boolean addBillBook(@JsonView(WriteView.class) @RequestBody BillItemDto billItemDto) {
        return billManageService.addBillBook(billItemDto);
    }

    @Operation(summary = "更新账本类型")
    @PutMapping("/book/{id}")
    public Boolean updateBillBook(@PathVariable("id") Long id,
                                  @JsonView(WriteView.class) @RequestBody BillItemDto billItemDto) {
        return billManageService.updateBillBook(id, billItemDto);
    }

    @Operation(summary = "新增账单类型")
    @PostMapping("/category")
    public Boolean addBillCategory(@RequestBody BillCategoryDto billCategoryDto) {
        return billManageService.addBillCategory(billCategoryDto);
    }

    @Operation(summary = "更新账单类型")
    @PutMapping("/category/{id}")
    public Boolean updateBillCategory(@PathVariable("id") Long id,
                                      @RequestBody BillCategoryDto billCategoryDto) {
        return billManageService.updateBillCategory(id, billCategoryDto);
    }
}
